package cumeo89.chii.client.entry.renderer;

import com.google.gwt.xml.client.Element;
import com.google.gwt.xml.client.Node;

import cumeo89.chii.client.entry.AbstractRenderer;
import cumeo89.chii.client.entry.Constants;
import cumeo89.chii.client.ui.ExtendedPanel;
import cumeo89.chii.client.ui.SeperatedPanel;
import cumeo89.chii.client.ui.TrivialPanel;

class SeperatedListRenderer extends AbstractRenderer {

	private SeperatedPanel pnlContainer = new SeperatedPanel("span", ", ");
	private TrivialPanel pnlTitle = new TrivialPanel("span");
	private TrivialPanel pnlContent = new TrivialPanel("span");
	
	public SeperatedListRenderer() {
		// set style name later 
		
		pnlTitle.setStyleName("slist-title");
		pnlContent.add(pnlTitle);
		
		pnlContainer.setStyleName("slist-content");
		pnlContent.add(pnlContainer);
		initWidget(pnlContent);
	}

	@Override
	protected ExtendedPanel getChildContainer() {
		return pnlContainer;
	}

	public void prepareWidget(Node node, boolean selected) {
		super.prepareWidget(node, selected);
		String tag = ((Element) node).getTagName();
		if (Constants.E_CATEGORY_LIST.equals(tag)) {
			pnlContent.setStyleName("category-list");
			pnlTitle.setHTML("Thể&nbsp;loại:&nbsp;");
		} else if (Constants.E_INTERWIKI_LIST.equals(tag)) {
			pnlContent.setStyleName("interwiki-list");
			pnlTitle.setHTML("LK&nbsp;liên&nbsp;wiki:&nbsp;");
		}
	}

	@Override
	public Node getAboveNode(Node child) {
		return null;
	}

	@Override
	public Node getBottomNode(Node child) {
		return null;
	}

}
